package com.emily.test.utils;

import com.emily.test.service.RedisService;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author ：zc
 * @date ：Created in 2019/4/4 19:24
 * @description：
 */
public class HeaderUtil {

    public static int getCompanyId(HttpServletRequest request, RedisService redisService) {
        String token = request.getHeader("token");
        System.out.println("token====" + token);
        Map<String, Object> userMap = (Map<String, Object>) redisService.get(token);
        Integer id = (Integer) userMap.get("companyId");
        if (ConstentUtil.isEmpty(id)) {
            return 0;
        }
        return id;
    }
    public static String getCompanyCode(HttpServletRequest request, RedisService redisService) {
        String token = request.getHeader("token");
        System.out.println("token====" + token);
        Map<String, Object> userMap = (Map<String, Object>) redisService.get(token);
        String code = userMap.get("companyCode").toString();
        if (ConstentUtil.isEmpty(code)) {
            return null;
        }
        return code;
    }
}
